<%--
  Created by IntelliJ IDEA.
  User: dqf
  Date: 2014/12/9
  Time: 17:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://"
          + request.getServerName() + ":" + request.getServerPort()
          + path + "/";
%>
<div class="row">
  <!-- NEW WIDGET START -->
  <article class="col-sm-12 col-md-12 col-lg-12">
    <div class="jarviswidget well" id="wid-id-3"
         data-widget-colorbutton="false"
         data-widget-editbutton="false"
         data-widget-togglebutton="false"
         data-widget-deletebutton="false"
         data-widget-fullscreenbutton="false"
         data-widget-custombutton="false"
         data-widget-sortable="false">
      <!-- widget div-->
      <div>
        <div class="widget-body">
          <a class="btn btn-default" id="btn-re-common" href="javascript:void(0)">
            <i class="fa fa-lg fa-mail-reply-all"></i>招标立项表
          </a>
          <s:if test="bidstart==null || bidstart.getProcessState().name()=='Draft'">
            <a class="btn btn-default pull-right pull-right-fix" id="btn-confirm-common" href="javascript:void(0);"><i class="fa fa-rocket"></i> 提交</a>
          </s:if>
          <s:if test="bidstart.getProcessState().name()=='Backed'">
            <a class="btn btn-default pull-right pull-right-fix" id="btn-recommit-common" href="javascript:void(0);"><i class="fa fa-rocket"></i> 再提交</a>
          </s:if>

          <a class="btn btn-default pull-right pull-right-fix" id="btn-save-common" href="javascript:void(0);"><i class="fa fa-lg fa-download"></i> 保存</a>
          <hr class="simple">
          <form id="bidstart" class="smart-form" novalidate="novalidate" action="" method="post">
            <input type="hidden" name="keyId" id="keyId" value="<s:property value="bidstart.id" />"/>
            <input type="hidden" name="curDutyId" id="curDutyId" value="<s:property value="curDutyId" />"/>

            <header id="title" style="display: block;">
              招标立项表
              <a href="javascript:void(0);" key="btn-bidstart-comment">
                                    <span class="txt-color-blueDark pull-right">
                                        <i class="fa-fw fa fa-comment-o"></i> 审批意见<span></span>
                                    </span>
              </a>
            </header>
            <fieldset>
              <div class="row">
                <label class="label col col-2">
                  <i class="fa fa-asterisk txt-color-red"></i>
                  项目名称
                </label>
                <section class="col col-5">
                  <label class="input">
                    <select name="projectid" class="form-control" >
                      <option value="">请选择</option>
                      <s:iterator value="projectArrayList" id="list">
                        <option  value="<s:property value="#list.id"/>" <s:property value="#list.selected"/> >
                          <s:property value="#list.name"/>
                        </option>
                      </s:iterator>
                    </select>
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">
                  <i class="fa fa-asterisk txt-color-red"></i>
                  招标类型
                </label>
                <section class="col col-5">
                  <label class="input">
                  <div class="inline-group state-error" >
                    <label class="radio" >
                      <input type="radio" name="type" value="0" <s:property value="bidstart.type==0?'checked':''"/> >
                      <i></i>勘察招标
                    </label>
                    <label class="radio" >
                      <input type="radio" name="type" value="1" <s:property value="bidstart.type==1?'checked':''"/> >
                      <i></i>设计招标
                    </label>
                  </div>
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">
                  <i class="fa fa-asterisk txt-color-red"></i>
                  招标方式
                </label>
                <section class="col col-5">
                  <label class="input">
                  <div class="inline-group state-error" >
                    <label class="radio" >
                      <input type="radio" name="method" value="0" <s:property value="bidstart.method==0?'checked':''"/> >
                      <i></i>公开招标
                    </label>
                    <label class="radio" >
                      <input type="radio" name="method" value="1" <s:property value="bidstart.method==1?'checked':''"/> >
                      <i></i>比选
                    </label>
                    <label class="radio" >
                      <input type="radio" name="method" value="2" <s:property value="bidstart.method==2?'checked':''"/> >
                      <i></i>邀标
                    </label>
                    <label class="radio" >
                      <input type="radio" name="method" value="3" <s:property value="bidstart.method==3?'checked':''"/> >
                      <i></i>抽签
                    </label>
                  </div>
                    </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">
                  招标方式原因说明
                </label>
                <section class="col col-5">
                  <label class="input">
                    <input name="reason" id="reason" placeholder="请输入招标方式原因说明"
                           type="text" value="<s:property value="bidstart.reason"/>">
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">
                  <i class="fa fa-asterisk txt-color-red"></i>
                  是否委托招标代理机构
                </label>
                <section class="col col-5">
                  <div class="inline-group" >
                    <label class="radio" >
                      <input type="radio" name="isDelegate" value="1" <s:property value="bidstart.isDelegate==1?'checked':''"/> id="hasDelegate">
                      <i></i>是
                    </label>
                    <label class="radio" >
                      <input type="radio" name="isDelegate" value="0" <s:property value="(bidstart==null||bidstart.isDelegate==0)?'checked':''"/> id="noDelegate"><i></i>否
                    </label>
                  </div>
                </section>
              </div>
              <div class="row" id="hidediv" style="<s:property value="(bidstart==null||bidstart.isDelegate==0)?'display: none;':'display: block;'"/>">
                <label class="label col col-2">
                  招标代理机构名称
                </label>
                <section class="col col-5">
                  <label class="input">
                    <input name="agentName" id="agentName" placeholder="请输入招标代理机构名称"
                           type="text" value="<s:property value="bidstart.agentName"/>">
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">拟启动招标时间</label>
                <section class="col col-2">
                  <label class="input">
                    <i class="icon-append fa fa-calendar"></i>
                    <input  class="hasDatepicker form-control" name="start" id="start" placeholder="请选择拟启动招标时间"
                            type="text" value="<s:date name="bidstart.start" format="yyyy-MM-dd"/>">
                  </label>
                </section>
              </div>
              <div class="row">
              <label class="label col col-2">招标大致内容</label>
              <section class="col col-5">
                <label class="input">
                  <input name="content" id="content" placeholder="请输入招标大致内容"
                         type="text" value="<s:property value="bidstart.content"/>">
                </label>
              </section>
            </div>
              <div class="row">
                <label class="label col col-2">
                  <i class="fa fa-asterisk txt-color-red"></i>
                  拟招标限额（拦标价）
                </label>
                <section class="col col-4">
                  <label class="input">
                    <input name="limitMoney" id="limitMoney" placeholder="请输入拟招标限额"
                           type="number" value="<s:property value="bidstart.limitMoney"/>">
                  </label>
                </section>
                <label class="label col money-unit-form">万元</label>
              </div>
              <div class="row">
                <label class="label col col-2">
                  <i class="fa fa-asterisk txt-color-red"></i>
                  招标文件上传
                </label>
                <section class="col col-5">
                  <label class="input">
                    <input  name="uploadify" id="file_upload1" placeholder="" type="file" >
                    <input name="fileId" id="fileId" style="display: none" value="<s:property value="bidstart.fileBidId"/>">
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">招标公告</label>
                <section class="col col-5">
                  <label class="input">
                    <input name="announce" id="announce" placeholder="请输入招标公告"
                           type="text" value="<s:property value="bidstart.announce"/>">
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">相关网站链接</label>
                <section class="col col-5">
                  <label class="input">
                    <input name="website" id="website" placeholder="请输入相关网站链接"
                           type="text" value="<s:property value="bidstart.website"/>">
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">备注</label>
                <section class="col col-5">
                  <label class="input">
                    <input name="mark" id="mark" placeholder="请输入备注"
                           type="text" value="<s:property value="bidstart.mark"/>">
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">提交人</label>
                <section class="col col-2">
                  <label class="input state-disabled">
                    <input value="<s:property value="procreater.getName()"></s:property>" placeholder="" type="text" disabled="disabled">
                  </label>
                </section>
                <label class="label col col-1">提交日期</label>
                <section class="col col-2">
                  <label class="input state-disabled">
                    <input value="<s:date name="bidstart.getCreateDate()" format="yyyy-MM-dd"></s:date>" placeholder="" type="text" disabled="disabled">
                  </label>
                </section>
              </div>
            </fieldset>
          </form>
        </div>
      </div>
    </div>
  </article>
</div>

<script>
  /*
   $("#isDelegate").onchange(function(){
   if (this.getAttr("isChecked") == "isChecked"){
   $("#hidediv").setAttr("style","display:none");
   }
   else{
   $("#hidediv").setAttr("style","display:block");
   }
   });
   */
  $("#btn-recommit-common").unbind().bind("click",function(e){
    var $valid = $("#bidstart").valid();

    if(!$valid){
      e.preventDefault();
      e.stopPropagation();
      return;
    }
    $.SmartMessageBox({
      title : "提示：",
      content : "确定再次提交申请吗？",
      buttons : '[取消][确认]'
    }, function(ButtonPressed) {
      if (ButtonPressed === "取消") {
        e.preventDefault();
        e.stopPropagation();
        return;
      }
      if (ButtonPressed === "确认") {
        var $validForm = $("#bidstart").valid();
        if(!$validForm) return false;
        $("#btn-recommit-common").attr("disabled", "disabled");
        form_save("bidstart","<%=path%>/com/ajax-bidstart!commit.action");
        loadURL("ajax!bidstart.action",$('#content'));
      }
    });
  });

  //返回视图
  $("#btn-re-common").click(function(){
    loadURL("ajax!bidstart.action",$('#content'));
  });
  //校验
  $("#bidstart").validate({
    rules : {
      projectid : {
        required : true

      },
      type : {
        required : true
      },
      method : {
        required : true
      },
      limitMoney : {
        required : true,
        number : true
      },
      fileBidId :{
        required : true
      }
    },
    messages : {
      projectid : {
        required : '请输入项目名称'
      },
      type : {
        required : '请选择招标类型'
      },
      method : {
        required : '请选择招标方式'
      },
      limitMoney : {
        required : '请输入金额',
        number : '请输入数字'
      },
      fileBidId : {
        required : '请上传招标文件'
      }
    },
    errorPlacement : function(error, element) {
      if(element.is(":radio")){

        error.insertAfter(element.parent().parent());
      }else{
        error.insertAfter(element.parent());
      }

    }
  });

  $('.hasDatepicker').datetimepicker({
    format: 'yyyy-mm-dd',
    weekStart: 1,
    autoclose: true,
    todayBtn: 'linked',
    language: 'zh-CN',
    minView:2
  });
  //保存
  $("#btn-save-common").click(
          function(e) {
            $.SmartMessageBox({
              title : "提示：",
              content : "确定提交申请吗？",
              buttons : '[取消][确认]'
            }, function(ButtonPressed) {
              if (ButtonPressed === "取消") {
                e.preventDefault();
                e.stopPropagation();
                return;
              }
              if (ButtonPressed === "确认") {
                $("#btn-save-common").attr("disabled", "disabled");
                form_save("bidstart","<%=path%>/com/ajax-bidstart!save.action");
                loadURL("ajax!bidstart.action",$('#content'));
              }
            });
          }
  );
  //提交
  $("#btn-confirm-common").click(
          function(e) {
            var $valid = $("#bidstart").valid();

            if(!$valid){
              e.preventDefault();
              e.stopPropagation();
              return;
            }
            $.SmartMessageBox({
              title : "提示：",
              content : "确定提交申请吗？",
              buttons : '[取消][确认]'
            }, function(ButtonPressed) {
              if (ButtonPressed === "取消") {
                e.preventDefault();
                e.stopPropagation();
                return;
              }
              if (ButtonPressed === "确认") {
                var $validForm = $("#bidstart").valid();
                if(!$validForm) return false;
                $("#btn-confirm-common").attr("disabled", "disabled");
                form_save("bidstart","<%=path%>/com/ajax-bidstart!commit.action");
                loadURL("ajax!bidstart.action",$('#content'));
              }
            });
          }
  );
  //上传文件
  inputLoad({
    objId:"file_upload1",
    entityName:"fileBidId",
    sourceId:"fileId"
  });

</script>
<script type="text/javascript">
  $(function(){multiDuty()});


  $("input#hasDelegate").unbind().bind("click",function(){
    $("#hidediv").show();
  });
  $("input#noDelegate").unbind().bind("click",function(){
    $("#hidediv").hide();
  });

  /*
   $(function(){
  <s:if test="prostudy !=null">
   var isDelgate = <s:property value="prostudy.isDelegate"></s:property>;
   $("input[name=isDelegate]").each(function(i,v){
   if(isDelgate == 1){
   $("#hidediv").show();
   }
   if($(v).val() == isDelgate){
   $(v).prop("checked",true);
   }else{
   $(v).prop("checked",false);
   }
   });
  </s:if>
   })
   */
</script>

